import axios from 'axios';
import { MateriailIssuanceInput } from '../models/warehous-materiai-input'
import { MateriailIssuanceInputPageInput } from '../models/warehous-materiai-page-input.'
import { AdminResultWarehouse } from '../models/result-pagelist-warehouse';
import { serveConfig } from '../../utils/axios-utils';

// Some imports not used depending on template conditions
// @ts-ignore


const BaseUrl = (window as any).__env__.VITE_API_URL
import { axiosInstance } from '/@/utils/axios-utils'

/** 
 * 获取所有设备
 * @param formData 查询参数
 * @returns 导入文件操作的响应结果
 */
export function GetMateriaiPageListApi(formData: MateriailIssuanceInputPageInput) {
  return axiosInstance<ResponseDate>({
    //responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/GetMateriaiPageList',
    method: 'POST',
    data: formData
  });
}
/** 
* 修改
* @param formData 导入的文件对象
* @returns 导入文件操作的响应结果
*/
export function UpdateMateriaiApi(formData: MateriailIssuanceInput) {
  return axiosInstance<ResponseDate>({
    //responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/UpdateMateriai',
    method: 'POST',
    data: formData
  });
}
/** 
* 新增
* @param file 导入的文件对象
* @returns 导入文件操作的响应结果
*/
export function InseertMateriaiApi(formData: MateriailIssuanceInput) {
  return axiosInstance<ResponseDate>({
    //responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/InsertMateriai',
    method: 'POST',
    data: formData
  });
}
interface ResponseDate<T = any> {
  code: string,
  message: string,
  result: T
}
/** 
 * 导出
 * @param data 导出条件
 * @param responseType 返回类型
 * @returns 导出文件
 */
export function MateriaiexportApi(data: any) {
  // 根据调用方式修改请求配置，添加 responseType 为 'blob'
  return axiosInstance<Blob>({
    responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/MateriaiExportExcel',
    method: 'POST',
    data
  })
}


/** 
* 导入文件操作
* @param file 导入的文件对象
* @returns 导入文件操作的响应结果
*/
export function MateriaiinportApi(formData: any) {
  return axiosInstance<ResponseDate>({
    //responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/ImportMateriai',
    method: 'POST',
    data: formData
  });
}

/**
* 下载文件
* @param data 上传所需参数
* @returns 上传文件的响应
* @example
* const response = await uploadApi({ file: file });
*/
export function DownloadMateriaiApi(params?: Record<string, any>) {
  return axiosInstance<Blob>({
    responseType: 'blob',
    url: BaseUrl + '/api/Materiailssuance/DownloadMateriai',
    method: 'Post',
    params
  });
}
/**
* 删除库位信息
*/
export function DeleteMateriaiApi(data: any) {
  return axiosInstance<ResponseDate>({

    url: BaseUrl + '/api/Materiailssuance/DeleteMateriai',
    method: 'Delete',
    data
  })
}

/**
 * 批量删除领料信息
 */
export function BatchDeleteMateriaiApi(data: any[]) {
  return axiosInstance<ResponseDate>({

    url: BaseUrl + '/api/Materiailssuance/BatchDeleteMateriai',
    method: 'Delete',
    data
  })
}